//
//  Person.m
//  MyBlocks
//
//  Created by apple on 2020/6/6.
//  Copyright © 2020 apple. All rights reserved.
//

#import "Person.h"

@implementation Person
//-(void)foo{
//    NSLog(@"Person---------foo");
//}

+(void)load{
    
    NSLog(@"Person --- load");
    
}
+(void)initialize{
    NSLog(@"Person --- initialize");
}
- (instancetype)initWithCoder:(NSCoder *)coder{
    unsigned int ivasCount ;
    Ivar *ivas = class_copyIvarList([Person class], &ivasCount);
    for (int i = 0; i < ivasCount ; i ++ ) {
        Ivar iva = ivas[i];
        NSString *key = [NSString stringWithUTF8String : ivar_getName(iva)];
        [self setValue:[coder decodeObjectForKey:key] forKey:key];
    }
    return self;
}
- (void)encodeWithCoder:(NSCoder *)coder{
    unsigned int ivasCount ;
    Ivar *ivas = class_copyIvarList([Person class], &ivasCount);
    for (int i = 0; i < ivasCount ; i ++ ) {
        Ivar iva = ivas[i];
        NSString *key = [NSString stringWithUTF8String:ivar_getName(iva)];
        [coder encodeObject:[self valueForKey:key]];
    }
}
-(NSString*)description{
    return [NSString stringWithFormat:@"name:%@",self.name];
}
@end
